<template>
  <div>
    <van-nav-bar title="请假详情" left-text="返回" left-arrow @click-left="onClickLeft" />
    <div style="padding:20px;">
      <img :src="'http://124.93.196.45:8087/prod-api'+infos.imgavater" v-if="infos.imgavater" />
      <p>
        学生姓名:
        <span>{{infos.studentName}}</span>
      </p>
      <p>
        班级:
        <span>{{infos.classs}}</span>
      </p>
      <p>
        请假开始时间:
        <span>{{infos.leaveTimeStart}}</span>
      </p>
      <p>
        请假结束时间:
        <span>{{infos.leaveTimeEnd}}</span>
      </p>
      <p>
        老师电话:
        <span>{{infos.usersNickTelephone}}</span>
      </p>
      <p>
        学生电话:
        <span>{{infos.studentTelephone}}</span>
      </p>
      <p>
        发病症状:
        <span>{{infos.onsetSymptoms}}</span>
      </p>
      <p>
        诊断疾病:
        <span>{{infos.diagnose}}</span>
      </p>
      <p>
        发病日期:
        <span>{{infos.morbidityTime}}</span>
      </p>
      <p>
        诊断日期:
        <span>{{infos.diagnosisTime}}</span>
      </p>
      <p>
        请假说明:
        <span>{{infos.leaveDetailes}}</span>
      </p>
      <p>
        请假类型:
        <span>{{infos.leaveType}}</span>
      </p>
      <p>
        离校状态:
        <span>{{infos.state}}</span>
      </p>
      <!-- <p>删除状态:<span>{{infos.isDetele}}</span></p> -->
    </div>
  </div>
</template>

<script setup>
import { useRoute } from "vue-router";
import { details } from "@/model/until";
import { onMounted, reactive, toRefs, watch } from "vue";

const route = useRoute();
const info = reactive({
  infos: {}
});
const onClickLeft = () => history.back();
onMounted(() => {
  details(route.params.id, {
    Authorization: window.localStorage.getItem("token")
  }).then(res => {
    console.log(res);
    info.infos = res.data.data;
    console.log(info.infos.imgavater);
  });
});
watch(
  () => info.infos.leaveType,
  () => {
    if (info.infos.leaveType === 0) {
      info.infos.leaveType = "事假";
    } else if (info.infos.leaveType === 1) {
      info.infos.leaveType = "病假";
    } else {
      info.infos.leaveType = "未标明";
    }
  }
);
watch(
  () => info.infos.state,
  () => {
    if (info.infos.state === 1) {
      info.infos.state = "已离校";
    } else {
      info.infos.state = "未离校";
    }
  }
);
// watch(()=>info.infos.isDetele,()=>{
//     if(info.infos.isDetele === 1){
//         info.infos.isDetele = '为删除'
//     }else{
//         info.infos.isDetele = '已删除'
//     }
// })
const { infos } = toRefs(info);
</script>

<style lang="scss" scoped>
span {
  margin-left: 10px;
}
</style>